<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="所属园区" prop="deptName">
        <el-input
          v-model="queryParams.deptName"
          placeholder="请输入所属园区"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="企业名称" prop="compName">
        <el-input
          v-model="queryParams.compName"
          placeholder="请输入企业名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="状态" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="请选择状态"
          clearable
          style="width: 100%"
        >
          <el-option
            v-for="dict in statusOptions"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:aqjcGcompanyRecord:add']"
        >新增</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:aqjcGcompanyRecord:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:aqjcGcompanyRecord:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:aqjcGcompanyRecord:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="aqjcGcompanyRecordList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="所属园区" align="center" prop="deptName" />
      <el-table-column label="企业" align="center" prop="compName" />
      <el-table-column label="检查人员" align="center" prop="createrName" />
      <el-table-column label="检查日期" align="center" prop="createTime" width="180" />
      <el-table-column label="复查人员" align="center" prop="operterName" />
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.check_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="企业检查类型" align="center" prop="typename" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:aqjcGcompanyRecord:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:aqjcGcompanyRecord:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改园区企业检查记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row :gutter="40">
          <el-col :span="7" style=" border-right: 1px solid rgb(204, 204, 204);">
            <el-form-item label="所属园区" prop="deptId" >
              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择" :disabled="true" />
            </el-form-item>
            <el-form-item label="企业" prop="compName" >
              <el-input v-model="form.compName" placeholder="请输入企业ID" :disabled="true" />
            </el-form-item>
            <el-form-item label="检查时间" prop="createTime" >
              <el-date-picker
                v-model="form.createTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                :disabled="true"
                >
              </el-date-picker>
            </el-form-item>

            <!-- <el-form-item label="操作人" prop="updateId">
              <el-input v-model="form.updateId" placeholder="请输入操作人" />
            </el-form-item> -->
            <!-- <el-form-item label="企业检查类型ID" prop="checktypeId">
              <el-select v-model="form.checktypeId" clearable @visible-change="(v) => querySelect(v, 'checkType')">
                <el-option
                  v-for="(item, index) in checkTypes"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item> -->
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
            <div v-if="form.status === 1">
              <el-form-item label="合格签名1" prop="okSign1">
                <div v-if="form.okSign1">
                  <img :src="form.okSign1" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('okSign1')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="okSign1" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('okSign1')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('okSign1')">重置</el-button>
                </div>
              </el-form-item>
              <el-form-item label="合格签名2" prop="okSign2">
                <div v-if="form.okSign2">
                  <img :src="form.okSign2" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('okSign2')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="okSign2" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('okSign2')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('okSign2')">重置</el-button>
                </div>
              </el-form-item>
              <el-form-item label="合格签名3" prop="okSign3">
                <div v-if="form.okSign3">
                  <img :src="form.okSign3" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('okSign3')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="okSign3" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('okSign3')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('okSign3')">重置</el-button>
                </div>
              </el-form-item>
            </div>
            <div v-if="form.status === 2">
              <el-form-item label="不合格签名1" prop="nookSign1">
                <div v-if="form.nookSign1">
                  <img :src="form.nookSign1" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('nookSign1')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="nookSign1" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('nookSign1')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('nookSign1')">重置</el-button>
                </div>
              </el-form-item>
              <el-form-item label="不合格签名2" prop="nookSign2">
                <div v-if="form.nookSign2">
                  <img :src="form.nookSign2" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('nookSign2')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="nookSign2" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('nookSign2')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('nookSign2')">重置</el-button>
                </div>
              </el-form-item>
              <el-form-item label="不合格签名3" prop="nookSign3">
                <div v-if="form.nookSign3">
                  <img :src="form.nookSign3" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('nookSign3')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="nookSign3" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('nookSign3')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('nookSign3')">重置</el-button>
                </div>
              </el-form-item>
            </div>
            <div v-if="form.status == 0 || form.status == 3">
              <el-form-item label="整改签名1" prop="todoSign1">
                <div v-if="form.todoSign1">
                  <img :src="form.todoSign1" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('todoSign1')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="todoSign1" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('todoSign1')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('todoSign1')">重置</el-button>
                </div>
              </el-form-item>
              <el-form-item label="整改签名2" prop="todoSign2">
                <div v-if="form.todoSign2">
                  <img :src="form.todoSign2" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('todoSign2')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="todoSign2" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('todoSign2')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('todoSign2')">重置</el-button>
                </div>
              </el-form-item>
              <el-form-item label="整改签名3" prop="todoSign3">
                <div v-if="form.todoSign3">
                  <img :src="form.todoSign3" style="width: 300px; height: auto;" />
                  <el-button type="primary" size="mini" @click="reSign('todoSign3')">重签</el-button>
                </div>
                <div v-else>
                  <vue-esign ref="todoSign3" style="width: 100%; height: 300px; border: 1px solid #ccc;" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />
                  <el-button type="primary" size="mini" @click="confirmSign('todoSign3')">提交</el-button>
                  <el-button type="danger" size="mini" @click="resetSign('todoSign3')">重置</el-button>
                </div>
              </el-form-item>
            </div>
          </el-col>

          <el-col :span="16">
            <el-form-item label="检查类型" prop="checktypeId">
              <el-select v-model="form.checktypeId"  @visible-change="(v) => querySelect(v, 'checkType')" @change="queryCheckInfo" disabled>
                <el-option
                  v-for="(item, index) in checkTypes"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="显示合格项" prop="showOk" label-width="90px">
              <el-switch
                v-model="form.showOk"
                active-color="#13ce66"
                inactive-color="#dadada"
                :active-value="1"
                :inactive-value="0"
              >
              </el-switch>
            </el-form-item>
            <div v-if="form.recorddtls.length">
              <div v-for="(item, index) in form.recorddtls" :key="index">
                <div v-show="item.isOk !== 1 || form.showOk" style="padding: 10px 0;border-top: 1px solid #ccc;">
                  <span style="margin-left:10px;width: 80px;font-size: 14px; font-weight:700; line-height:36px;display: inline-block">检查序号：</span>
                  <span style="margin-left:10px;width: 180px;font-size: 14px; font-weight:700">{{item.checkinfo}}</span>
                  <el-form-item label="检查内容" prop="checkinfoId">
                    <el-select v-model="item.checkinfo" disabled>
                      <el-option
                        v-for="info in checkInfos"
                        :key="info.value"
                        :label="info.label"
                        :value="info.value"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="检查照片" prop="checkPhotos">
                    <el-upload
                      :action="uploadUrl"
                      :file-list="item.checkPhotos"
                      list-type="picture-card"
                      class="upload"
                      :on-success="(res, file, fileList) => uploadImgSuccess(res, file, fileList, 'checkPhotos', item)"
                      :before-upload="file => uploadBefore(file, 'checkPhotos')"
                      :before-remove="delPhoto"
                    >
                      <i class="el-icon-plus"></i>
                    </el-upload>
                  </el-form-item>

                  <el-form-item label="是否合格" prop="isOk">
                    <div v-if="item.isOk === 1 && form.id"
                      style="color: #13ce66;"
                    >合格</div>
                    <div v-if="item.isOk === 0 && form.id"
                      style="color: #ff4949;"
                    >不合格</div>
                    <el-switch
                      v-model="item.isOk"
                      v-if="!form.id"
                      active-color="#13ce66"
                      inactive-color="#ff4949"
                      :active-value="1"
                      :inactive-value="0">
                    </el-switch>
                  </el-form-item>
                  <el-form-item v-if="item.isOk === 0" label="整改建议" prop="content">
                    <el-input v-model="item.content" disabled placeholder="请输入整改建议" />
                  </el-form-item>
                  <el-form-item v-if="item.isOk === 0 " label="整改照片" prop="rectifyPhotos">
                    <el-upload
                      :action="uploadUrl"
                      :file-list="item.rectifyPhotos"
                      list-type="picture-card"
                      class="upload"
                      :on-success="(res, file, fileList) => uploadImgSuccess(res, file, fileList, 'rectifyPhotos', item)"
                      :before-upload="file => uploadBefore(file, 'rectifyPhotos')"
                      :before-remove="delPhoto"
                    >
                      <i class="el-icon-plus"></i>
                    </el-upload>
                  </el-form-item>
                  <el-form-item v-if="item.isOk === 0 && item.gcompanyRecordId" label="是否合格" prop="status">
                    <el-switch
                      v-model="item.status"
                      active-color="#13ce66"
                      inactive-color="#dadada"
                      :active-value="1"
                      :inactive-value="0">
                    </el-switch>
                  </el-form-item>
                </div>
              </div>
            </div>
          </el-col>


        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listAqjcGcompanyRecord, getAqjcGcompanyRecord, delAqjcGcompanyRecord, addAqjcGcompanyRecord, updateAqjcGcompanyRecord } from "@/api/system/aqjcGcompanyRecord";
import {uploadUrl, uploadFile} from "@/api/system/config";
import { listRecord, getRecord, delRecord, addRecord, updateRecord, delphoto, share, importData } from "@/api/system/record";
import vueEsign from 'vue-esign'
import { deptTreeSelect } from '@/api/system/user' // 确保store正确初始化
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; // 引入样式
import { base64ToImg, formatDate1 } from '@/utils'
import { listChecktype } from '@/api/system/checktype'
import { listCheckinfo } from '@/api/system/checkinfo'

export default {
  name: "AqjcGcompanyRecord",
  dicts: [ 'check_status'],
  components: {
    vueEsign,
    Treeselect // 添加 Treeselect 组件注册
  },
  data() {
    return {
      // 部门树选项
      deptOptions: undefined,
      cascaderValue: null,
      uploadUrl,
      // 新增状态字典
      statusOptions: [
        { value: '0', label: '整改' },
        { value: '1', label: '合格' },
        { value: '2', label: '不合格' },
        { value: '3', label: '待复查' }
      ],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 企业检查类型
      checkTypes: [],
      getFormStatus: 1,
      date: [],
      isCrop: false,          // ←新增
      lineWidth: 6,           // ←新增
      lineColor: '#000000',   // ←新增
      bgColor: '',     // ←新增
      checkInfos: [],
      // 总条数
      total: 0,
      // 园区企业检查记录表格数据
      aqjcGcompanyRecordList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        deptId: null,
        companyId: null,
        createId: null,
        updateId: null,
        status: null,
        checktypeId: null,
        okSign1: null,
        okSign2: null,
        okSign3: null,
        nookSign1: null,
        nookSign2: null,
        nookSign3: null,
        todoSign1: null,
        todoSign2: null,
        todoSign3: null
      },
      // 表单参数
      form: {
        recorddtls: [],
      },
      // 表单校验
      rules: {
        deptId: [
          { required: true, message: "所属园区ID不能为空", trigger: "blur" }
        ],
        companyId: [
          { required: true, message: "企业ID不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.querySelect(true, 'checkType'); // 主动加载数据
    this.getDeptTree();
    this.getList();
  },
  // 遍历方法

  methods: {
    /** 查询部门下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then(response => {
        this.deptOptions = response.data;
      });
    },
    confirmSign(type) {
      this.$refs[type].generate().then(res => {
        console.log('reeeeeeee', res)
        const file = base64ToImg(res, type)
        const formData = new FormData()
        formData.append('file', file)
        uploadFile(formData).then(res => {
          console.log('res', res)
          // this.form[type] = res.fileName
          this.$set(this.form, type, res.fileName)
        })
      }).catch(err => {
        alert(err) // 画布没有签字时会执行这里 'Not Signned'
      })
    },
    uploadBefore(file, type) {
      console.log('file', file)
      const isJPG = ['image/jpeg', 'image/png'].includes(file.type);
      const isLt2M = file.size / 1024 / 1024 < 5;

      if (!isJPG) {
        this.$message.error('上传图片只能是 JPG,PNG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传图片大小不能超过 5MB!');
      }
      return isJPG && isLt2M;
    },
    uploadImgSuccess(res, file, fileList, type, item) {
      console.log('====', type,item)
      let typeTmp
      switch (type) {
        case 'checkPhotos':
          typeTmp = 3
          break
        case 'rectifyPhotos':
          typeTmp = 4
          break
        default:
      }
      item[type] = [
        ...item[type],
        ...[
          {
            gtype: typeTmp,
            imgUrl: res.fileName,
            gcompanyRecorddtlId: item.id
          }
        ]
      ]
    },
    resetSign(type) {
      this.$refs[type].reset()
    },
    reSign(type) {
      this.form[type] = ''
    },
    queryCheckInfo(v) {

      const params = {
        typeId: v,
        pageNum: 1,
        pageSize: 1000
      }
      listCheckinfo(params).then(res => {
        this.checkInfos = res.rows.map(item => {
          return {
            value: item.id,
            label: item.content
          }
        })
        //
        // this.form.recorddtls = res.rows.map(item => {
        //   return {
        //     checkinfoid: item.id,
        //     checkPhotos: [],
        //     isOk: 1,
        //     content: item.zgjy,
        //     rectifyPhotos: [],
        //     status: 1
        //   }
        // })
        // console.log('infos', this.checkInfos, this.form)
      })
    },
    /** 查询园区企业检查记录列表 */
    getList() {
      this.loading = true;
      listAqjcGcompanyRecord(this.queryParams).then(response => {
        this.aqjcGcompanyRecordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        deptId: null,
        companyId: null,
        createTime: null,
        createId: null,
        updateId: null,
        updateTime: null,
        status: null,
        checktypeId: null,
        remark: null,
        okSign1: null,
        okSign2: null,
        okSign3: null,
        nookSign1: null,
        nookSign2: null,
        nookSign3: null,
        todoSign1: null,
        todoSign2: null,
        todoSign3: null,
        recorddtls: []   // 这里加上
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 类型选择
    querySelect(v, type) {
      console.log('--------------', v, type)
      if (!v) return
      switch (type) {
        case 'checkType':
          listChecktype().then(res => {
            console.log('ressssss', res)
            this.checkTypes = res.rows.map(item => {
              return {
                value: item.id,
                label: item.typename
              }
            })
          })
          break
        default :
      }
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加园区企业检查记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids



      getAqjcGcompanyRecord(id).then(response => {
        this.form = response.data;
        console.log('this.form', this.form)
        if (Array.isArray(this.form.recorddtls)) {
          this.form.recorddtls.forEach(item => {
            item.checkPhotos = item.imgList
              ?.filter(img => img.gtype === 3)
              .map(img => ({
                url: img.imgUrl
              })) || [];

            item.rectifyPhotos = item.imgList
              ?.filter(img => img.gtype === 4)
              .map(img => ({
                url: img.imgUrl
              })) || [];
          });
        }
        this.queryCheckInfo(this.form.checktypeId);
        this.open = true;
        this.title = "修改园区企业检查记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      console.log('form', this.form)
      this.isSubmit = true
      for (let i = 0; i < this.form.recorddtls.length; i++) {
        this.form.recorddtls[i].imgList = []
        this.form.recorddtls[i].imgList = [
          ...this.form.recorddtls[i].checkPhotos || [],
          ...this.form.recorddtls[i].rectifyPhotos || []
        ]
      }
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateAqjcGcompanyRecord(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addAqjcGcompanyRecord(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除园区企业检查记录编号为"' + ids + '"的数据项？').then(function() {
        return delAqjcGcompanyRecord(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    delPhoto (file, fileList) {
      console.log('file', file)
      if (!file.id) return
      const params = {
        id: file.id
      }
      delphoto(params)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/aqjcGcompanyRecord/export', {
        ...this.queryParams
      }, `aqjcGcompanyRecord_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
